package com.personal.enums;



/**
 * @author 萌新
 * @version 1.0
 * @date 2021/4/17 21:07
 */

public enum ProductCategoryStateEnum {
    /**/
    INNER_ERROR(-1001,"操作失败"), NULL_SHOP(-1002,"shop信息为空"),
    SUCCESS(1,"操作成功"),EMPETY_LIST(-1003,"请输入商品目录信息");

    private int state;
    private String stateInfo;

    private ProductCategoryStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    /**
     * 通过state获取productCategoryStateEnum,从而可以调用ProductCategoryStateEnum
     * #getStateInfo()获取stateInfo
     * @param index
     * @return
     */
    public static ProductCategoryStateEnum stateOf(int index){
        for (ProductCategoryStateEnum productCategoryStateEnum: values()){
            if (productCategoryStateEnum.getState() == index){
                return productCategoryStateEnum;
            }
        }
        return null;
    }

}
